#TOOL_PATH     := /opt/arm-2010.09
#LIBC_PATH     := $(TOOL_PATH)/arm-none-linux-gnueabi/libc/lib
#COMPILER_PATH := $(TOOL_PATH)/bin
#TOOL_PERFIX :=
#CROSS_COMPILE := $(COMPILER_PATH)/$(TOOL_PERFIX)

CXX     = $(CROSS_COMPILE)g++
CC      = $(CROSS_COMPILE)gcc
AR      = $(CROSS_COMPILE)ar
LD      = $(CROSS_COMPILE)ld
STRIP   = $(CROSS_COMPILE)strip
OBJDUMP = $(CROSS_COMPILE)objdump
NM      = $(CROSS_COMPILE)nm

ifeq (,$(ARCH))
ARCH = x86
endif

NDB = libndb.so
NDB_SRCS = nano_db.c nano_db.h
NDB_OBJS = nano_db.o

TARGET =  ndb_test 
OBJECTS = example.o
SOURCE = example.c

#  default target
all: $(TARGET) test_container

CFLAGS = -g -Wall -O2 -fPIC -I. -I./include/libxml2
LDFLAGS = -L./lib/$(ARCH) -lxml2


CXXFLAGS = $(CFLAGS)

DEBUG_FLAG = 

$(NDB_OBJS): $(NDB_SRCS)
	$(CC) $(CFLAGS) -c $< -o $@

$(NDB):$(NDB_OBJS)
	$(CC) -shared $(LDFLAGS) $< -o $@

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

$(TARGET): $(OBJECTS) $(NDB)
	$(CC) $(LDFLAGS) $(DEBUG_FLAG) -o $@ $(OBJECTS) -L. -lndb

test_container: test_container.o  $(NDB)
	$(CC) $(LDFLAGS) $(DEBUG_FLAG) -o $@ test_container.o -L. -lndb

clean:
	rm -f *.o *.so test_container ndb_test

install: $(TARGET)

